// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
//引入elementui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

import "@/assets/css/media.css"; //媒体查询

Vue.config.productionTip = false
// 安装 ElementUI
Vue.use(ElementUI);
/* eslint-disable no-new */

//每次路由跳转之前
router.beforeEach((to, form, next) => {
  let isLogin = sessionStorage.getItem('isLogin')
  //注销登录
  if(to.path == 'index'){
    //清楚状态
    sessionStorage.clear();
    //跳转登录页
    next('/');
  }else if(to.path == '/'){
    // 判断是否登录，如果登录直接去首页
    if(null != isLogin){
      // 如果为空，直接去登录页
      next('/index')
    }
  }else if(null == isLogin){
    next('/');
  }
  next();
})

new Vue({
  el: '#app',
  router,
  components: {
    App
  },
  template: '<App/>'
})
